Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use initial pen up value on cancel instead of an arbitrary value #163

Merged
merged 2 commits into from
Feb 16, 2025

Conversation

drskullster
Copy link

Currently, when cancelling a plot the pen up value is arbitrarily set to 50. This PR makes it so it uses the initial pen up value (the same value that's used in the prePlot phase).

@drskullster drskullster force-pushed the fix-pen-height-on-cancel branch from 72b6ac5 to 7e517b8 Compare February 16, 2025 09:10
@@ -170,10 +170,8 @@ export async function startServer (port: number, hardware: Hardware = 'v3', com:
async executeMotion(motion: Motion, _progress: [number, number]): Promise<void> {
await ebb.executeMotion(motion);
},
async postCancel(): Promise<void> {
const device = Device(ebb.hardware);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drskullster did removing this line improve anything? Were there any side effects?

(I don't know its original purpose)

Copy link
Author

@drskullster drskullster Feb 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexrudd2 from what I understand the Device object was necessary to get the machine value for a specific position (device.penPctToPos(50)). Since we now pass the position from the first pen motion on line 225 this is not needed anymore.

Copy link
Owner

@alexrudd2 alexrudd2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your pull requests! I'm glad to get back to feature improvements.

Apologies in advance for not knowing the code particularly well; I only took over as maintainer recently :)

@@ -189,7 +187,7 @@ export async function startServer (port: number, hardware: Hardware = 'v3', com:
console.log(`Motion ${progress[0] + 1}/${progress[1]}`);
await new Promise((resolve) => setTimeout(resolve, motion.duration() * 1000));
},
async postCancel(): Promise<void> {
async postCancel(_initialPenHeight: number): Promise<void> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2 implementations should be kept in sync. (See #164 (comment)).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexrudd2 so this is the simPlotter object that as far as I understand doesn't implement any action and just logs them. Interestingly the webserial implementation already checks for the pen up original position (or falls back to 50):

saxi/src/ui.tsx

Line 185 in 03df63e

const penUpPosition = penMotion ? Math.max(penMotion.initialPos, penMotion.finalPos) : device.penPctToPos(50);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on the simPlotter.

Regarding the WebSerial implementation, that's probably the more robust implementation. The Math.max is screwy, but is actually intended to make things work with reversed output pins (where commanding the pen up actually moves it down),

Copy link
Owner

@alexrudd2 alexrudd2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll file a separate issue for syncing up the WebSerial and NodeSerialPort implementations instead of blocking this PR.

@alexrudd2 alexrudd2 merged commit 8f4e59e into alexrudd2:main Feb 16, 2025
6 checks passed
@drskullster drskullster deleted the fix-pen-height-on-cancel branch February 23, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants